package com.itheima.reggie.controller;

import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Setmeal;
import com.itheima.reggie.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;
    //http://localhost:8081/setmeal/list?categoryId=1413342269393674242&status=1
    @Cacheable(value = "setmeal" ,key = "#categoryId")
    @GetMapping("/list")
    public ResultInfo selectByCategoryId(Long categoryId,@RequestParam(defaultValue = "1") Integer status){
        List<Setmeal> setmealList=setmealService.selectByCategoryId(categoryId,status);
        return ResultInfo.success(setmealList);
    }
}
